﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MadLibrary.Web
{
    /// <summary>
    /// Represents attribute of HTML element.
    /// </summary>
    public class HtmlAttribute : IBuildable
    {
        /// <summary>
        /// Gets or sets name of current attribute.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets value of current attribute.
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// Creates new empty HtmlAttribute object.
        /// </summary>
        public HtmlAttribute()
        {
            this.Name = "";
            this.Value = "";
        }

        /// <summary>
        /// Creates HtmlAttribute object with specified name and specified value.
        /// </summary>
        /// <param name="Name">Specifies name of new attruibute.</param>
        /// <param name="Value">Specifies value of new attribute.</param>
        public HtmlAttribute(string Name, string Value)
        {
            this.Name = Name;
            this.Value = Value;
        }

        /// <summary>
        /// Generates string from current attribute.
        /// </summary>
        /// <returns>String generated from current attribute.</returns>
        string IBuildable.Build()
        {
            return String.Format(" {0}=\"{1}\"", this.Name, this.Value);
        }
    }
}